import React from 'react'
import { connect } from 'react-redux'

class Total extends React.Component {
  render() {
    // console.log(this.props);
    const { total } = this.props
    return <div>商品总数：【{total}】</div>
  }
}

const mapStateToProps = state => {
  // console.log(state);
  const {num1, num2, num3} = state
  let total1 = num1+ num2 + num3
  return {
    total: total1
  }
}
// const WithComponent = connect(mapStateToProps)
// export default WithComponent(Total)
export default connect(mapStateToProps)(Total)
